﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace HeathCareSystem
{
    public class XetNghiemDAO
    {
        DataProvider dp = new DataProvider();
        //them mot xet nghiem moi
        public bool ThemXetNghiemMoi(XetNghiemDTO xnDTO)
        {
            string strSQL = string.Format("INSERT INTO XetNghiem (TenXetNghiem) " +
                                          "VALUES (N'{0}')",
                                            xnDTO.tenXetNghiem);
            return dp.ExecuteNonQuery(strSQL);
        }

        //cap nhat mot xet nghiem
        public bool CapNhatXetNghiem(XetNghiemDTO xnDTO)
        {
            string strSQL = string.Format("UPDATET XetNghiem " +
                                          "SET TenXetNghiem = N'{0}'" +
                                          "WHERE MaXetNghiem = '{1}'",
                                            xnDTO.tenXetNghiem, xnDTO.maXetNghiem);
            return dp.ExecuteNonQuery(strSQL);
        }

        //xoa mot xet nghiem
        public bool XoaXetNghiem(XetNghiemDTO xnDTO)
        {
            string strSQL = string.Format("DELETE FROM XetNghiem" +
                                          "WHERE  (MaXetNghiem = '{0}')",
                                            xnDTO.maXetNghiem);
            return dp.ExecuteNonQuery(strSQL);
        }

        public DataTable LayDanhSachXetNghiem()
        {
            string strSQL = string.Format("SELECT TenXetNghiem FROM XetNghiem");
            return dp.ExecuteQuery(strSQL);
        }
    }
}